import pygame,sys
pygame.init()
screen = pygame.display.set_mode((800,600))
# 最小生成树
# 连通图的最小连通子图--最优子结构
# Prim & Kruska
# Prim
# 保证连通情况，权重最小的边
# Kruska
# 保证无回路情况，权重最小的边

# 什么时候用Prim算法？
# 稠密图


p_G = pygame.image.load('./p_G.png')
n_G = pygame.image.load('./n_G.png')
k_G = pygame.image.load('./k_G.png')
p_Grect = p_G.get_rect()
n_Grect = n_G.get_rect()
k_Grect = k_G.get_rect()


while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                sys.exit()
            elif event.key == pygame.K_p:
                screen.blit(n_G,n_Grect)
                pygame.display.update()
            elif event.key == pygame.K_k:
                screen.blit(k_G,k_Grect)
                pygame.display.update()
        if event.type == pygame.KEYUP:
            if event.key == pygame.K_p:
                screen.blit(p_G,p_Grect)
                pygame.display.update()
            elif event.key == pygame.K_k:
                screen.blit(p_G,p_Grect)
                pygame.display.update()
    screen.fill((0,0,0))
   

